<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui" template="/layout/principal.xhtml">

    <ui:define name="content">

        <h1 class="title ui-widget-header ui-corner-all">
            <h:outputText value="Listado de Campañas" />
        </h1>

        <h:form>

            <p:growl id="growl" showDetail="true" life="3000" />

            <p:panel header="Filtro">
                <h:panelGrid columns="2">
                    <h:outputLabel value="Estado : " for="estadoId" />
                    <p:selectOneMenu id="estadoId" value="#{master.estado}" style="width: 200px;">
                        <f:selectItem itemLabel="Todos" itemValue="" />
                        <f:selectItem itemLabel="Activa" itemValue="A" />
                        <f:selectItem itemLabel="Inactiva" itemValue="I" />
                        <f:selectItem itemLabel="Terminada" itemValue="T" />
                        <p:ajax update="dttCamapign" listener="#{master.actualizarLista}" />
                    </p:selectOneMenu>
                </h:panelGrid>
            </p:panel>

            <p:dataGrid id="dgMaster" var="m" value="#{master.listMaster}" columns="3" rows="10" paginator="true"
                effect="true">
                <p:column>
                    <p:panel header="#{m.name}" style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">

                            <p:commandLink title="Encender" action="#{master.encender}">
                                <p:graphicImage value="/images/encender.jpg" />
                                <f:setPropertyActionListener value="#{car}" target="#{tableBean.selectedCar}" />
                            </p:commandLink>

                            <p:commandLink title="Apagar" action="#{master.apagar}">
                                <p:graphicImage value="/images/apagar.jpg" />
                                <f:setPropertyActionListener value="#{car}" target="#{tableBean.selectedCar}" />
                            </p:commandLink>
                        </h:panelGrid>
                    </p:panel>
                </p:column>
            </p:dataGrid>

            <p:panel header="Opciones">
                <h:panelGrid columns="5">
                    <p:commandButton value="Nuevo" action="goCrearMaster" style="width: 200px;" ajax="false" />
                    <p:commandButton value="Activar" action="#{master.activar}" update="dgMaster" style="width: 200px;" />
                    <p:commandButton value="Desactivar" action="#{master.desactivar}" update="dgMaster"
                        style="width: 200px;" />
                    <p:commandButton value="Eliminar" action="#{master.eliminar}" update="dgMaster"
                        style="width: 200px;" />
                </h:panelGrid>
            </p:panel>

        </h:form>

    </ui:define>
</ui:composition>